package com.holly.unit.deform.api.pojo.component;

import com.holly.unit.system.api.pojo.organization.HrOrganizationDTO;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 类描述: 封装树结构的组织机构的名称的实体类
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/4/16 11:51
 */
public class OrgIdDTO implements Serializable {

    private static final long serialVersionUID = 1L;
    // 主键ID
    private String key;

    // 主键ID
    private String value;

    // 部门名称
    private String title;

    List<OrgIdDTO> children = new ArrayList<>();

    /**
     * 将SysDepartTreeModel的部分数据放在该对象当中
     * @param treeModel
     * @return
     */
    public OrgIdDTO convert(DeformDeptTreeDTO treeModel) {
        this.key = String.valueOf(treeModel.getOrgId());
        this.value = String.valueOf(treeModel.getOrgId());
        this.title = treeModel.getOrgName();
        return this;
    }

    /**
     * 该方法为用户部门的实现类所使用
     * @param sysDepart
     * @return
     */
    public OrgIdDTO convertByUserDepart(HrOrganizationDTO sysDepart) {
        this.key = String.valueOf(sysDepart.getOrgId());
        this.value = sysDepart.getOrgId().toString();
        this.title = sysDepart.getOrgName();
        return this;
    }

    public List<OrgIdDTO> getChildren() {
        return children;
    }

    public void setChildren(List<OrgIdDTO> children) {
        this.children = children;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

}
